<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>表格插入图片</title>
</head>

<body>
<table id="myTable" border="1">
    <tr>
        <td>单元格 1</td>
        <td>单元格 2</td>
    </tr>
    <tr>
        <td>单元格 3</td>
        <td>单元格 4</td>
    </tr>
</table>
<input type="file" accept="image/*" onchange="insertImage(event)">

<script>
    function insertImage(event) {
        const file = event.target.files[0];
        if (file) {
            const reader = new FileReader();
            reader.onload = function (e) {
                const img = document.createElement('img');
                img.src = e.target.result;
                img.alt = '插入的图片';
                img.style.maxWidth = '50px';
                img.style.maxHeight = '50px';
                const table = document.getElementById('myTable');
                const row = table.insertRow(-1);
                const cell = row.insertCell(0);
                cell.appendChild(img);
            };
            reader.readAsDataURL(file);
        }
    }
</script>
</body>

</html>